package com.guli.gulimall.gulimallproduct.feign;
import com.guli.common.utils.ImageBeans;
import com.guli.common.utils.R;
import com.guli.gulimall.gulimallproduct.config.FeignMultipartSupportConfig;
import io.swagger.annotations.ApiOperation;
import org.springframework.boot.context.properties.bind.DefaultValue;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.awt.image.BufferedImage;
import java.io.IOException;

//@FeignClient(value = "gulimallThirdParty",configuration = {FeignMultipartSupportConfig.class})
@FeignClient(value = "gulimallThirdParty")
public interface COSForignService {

    @PostMapping("/gulimall/thirdParty/qclolud/createBucket/{name}")
    @ApiOperation("创建桶")
    public R createBucket(@PathVariable String name);


    @PostMapping("/gulimall/thirdParty/qclolud/listBucket")
    @ApiOperation("查询桶")
    public R listBucket() throws IOException;

    @PostMapping("/gulimall/thirdParty/qclolud/delBucket/{bucketName}")
    @ApiOperation("删除桶")
    public R delBucket(@PathVariable String bucketName);

    @PostMapping(value = "/gulimall/thirdParty/qclolud/upload/{brand_id}/{bucketName}/{localPath}",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    @ApiOperation("上传对象")
    public R uploadObject(@RequestPart("file") MultipartFile file, @PathVariable String brand_id,
                          @PathVariable String bucketName, @PathVariable String localPath);

    @GetMapping(value = "/gulimall/thirdParty/qclolud/download")
    @ApiOperation(value = "下载图像")
     public ImageBeans getKaptchaImage(@RequestParam("path") String path);

    @Deprecated
    @PostMapping(value = "/gulimall/thirdParty/qclolud/uploadurl/{bucketName}/{localPath}/{filename}")
    @ApiOperation(value = "通过预签名上传对象")
    public R generatePresignedUploadUrl(@PathVariable String bucketName, @PathVariable String localPath, @PathVariable String filename);

    @GetMapping(value = "/gulimall/thirdParty/qclolud/downloadurl")
    @ApiOperation(value = "通过预签名下载对象")
    public R generatePresigneddownloadurl( @RequestParam("bucketName") String bucketName,@RequestParam("path") String path);

    @PostMapping(value = "/gulimall/thirdParty/qclolud/tempS/{bucketName}/{path}/{filename}")
    @ApiOperation("获取临时秘钥,用于上传对象")
    public R getTempSecret(@PathVariable String bucketName, @PathVariable String path, @PathVariable String filename,@RequestParam(defaultValue = "ap-chongqing") String region);

}
